﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public class News
{
    public int No { get; set; }
    public string ID { get; set; }
    public string Name { get; set; }
    public DateTime Date { get; set; }
}
public partial class _Default : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        List<News> list = CreateList();

        Paging paging = new Paging(list.Count());
        paging.PerPage = 10;
        //paging.CurrentMode = Mode.None;
        paging.CurrentPage = Convert.ToInt32(Request["page"]);
        lblPagination.Text = paging.BuildPaging();
        list = list.Skip((paging.CurrentPage * paging.PerPage) - paging.PerPage).Take(paging.PerPage).ToList();
        rptGrid.DataSource = list;
        rptGrid.DataBind();
    }

    public List<News> CreateList()
    {
        List<News> list = new List<News>();

        for (int i = 1; i <= 100; i++)
        {
            News item = new News();
            item.No = i;
            item.ID = Guid.NewGuid().ToString();
            item.Name = "Title " + i;
            item.Date = DateTime.Now.AddDays(new Random().Next(-10, 10));
            list.Add(item);
        }

        return list;
    }
}